using System;
using System.Drawing;
using System.Windows.Forms;

namespace Pegasus.Windows.Forms
{
	/// <summary>
	/// This class provides information and settings for the system desktop
	/// </summary>
	public static class Desktop
	{
		/// <summary>
		/// Gets an array of all displays that make up the desktop.
		/// </summary>
		/// <value>The array of screen objects.</value>
		public static Screen[] Displays
		{
			get
			{
				return Screen.AllScreens;
			}
		}

		/// <summary>
		/// Gets the primary display.
		/// </summary>
		/// <value>The primary display.</value>
		public static Screen PrimaryDisplay
		{
			get
			{
				return Screen.PrimaryScreen;
			}
		}

		/// <summary>
		/// Gets the bounds for the users desktop.  Note that if you have muliple monitors
		/// that are not directly aligned is 
		/// </summary>
		/// <value>The desktop bounds.</value>
		public static Rectangle Bounds 
		{
			get
			{
				Rectangle desktopRect = new Rectangle();
				foreach( Screen screen in Screen.AllScreens )
				{
					Rectangle bounds = screen.Bounds;
					desktopRect.X = Math.Min( bounds.X, desktopRect.X );
					desktopRect.Y = Math.Min( bounds.Y, desktopRect.Y );
					desktopRect.Width = Math.Max( bounds.Right, desktopRect.Right ) - desktopRect.X;
					desktopRect.Height = Math.Max( bounds.Bottom, desktopRect.Bottom ) - desktopRect.Y;
				}

				return desktopRect;
			}
		}
	}
}
